package com.design.javaManage.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


//跨域处理

@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry
                //允许访问的路径
                .addMapping("/**")
                //配置请求的来源
                .allowedOrigins("http://localhost:8081")
                //允许跨域访问的方法
                .allowedMethods("GET","POST","DELETE","PUT")
                //是否携带参数
                .allowCredentials(true)
                .allowedHeaders("*")
                //最大效应时间
                .maxAge(3600);
    }
}

